<?php

use yii\db\Schema;
use yii\db\Migration;

class m150313_091532_update_city_weather extends Migration
{
    public function up()
    {
		$sql =<<<FINE
-- ----------------------------
-- Table structure for city_weather
-- ----------------------------
DROP TABLE IF EXISTS {{%city_weather}};
CREATE TABLE {{%city_weather}} (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  zone_id int(11) DEFAULT NULL COMMENT '地域 id, zone 表自增键',
  weather_zone_id varchar(16) DEFAULT NULL COMMENT '对应天气网城市代码',
  aqi_zone_id varchar(16) DEFAULT NULL COMMENT '对应污染指数来源网站的城市代码',
  zone_code text COMMENT '城市（地域）代码',
  zone_name text COMMENT '城市名称',
  average_temparature_id int(11) DEFAULT NULL COMMENT '平均温度类型，取值 4 - 13',
  humidity_id int(11) DEFAULT NULL COMMENT '湿度类型，取值 14 -16',
  aqi_id int(11) DEFAULT NULL COMMENT 'AQI Air Quality Index, 空气质量指数 id, 取值 17 - 22',
  status int(1) NOT NULL DEFAULT '1' COMMENT '1 有效， 0 无效（删除或其他情况）',
  last_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of city_weather
-- ----------------------------
INSERT INTO {{%city_weather}} VALUES ('1', '7', 'beijing', 'c_beijing', 'CNBJ0000', '北京', '8', '16', '17', '1', '2015-03-13 15:42:35');
INSERT INTO {{%city_weather}} VALUES ('2', '221', 'tianjin', 'c_tianjin', 'CNTJ0000', '天津', '8', '16', '18', '1', '2015-03-13 15:42:35');
INSERT INTO {{%city_weather}} VALUES ('3', '222', 'shanghai', 'c_shanghai', 'CNSH0000', '上海', '9', '16', '19', '1', '2015-03-13 15:42:35');
INSERT INTO {{%city_weather}} VALUES ('4', '156', 'chongqing', 'c_chongqing', 'CNCQ0000', '重庆', '9', '16', '19', '1', '2015-03-13 08:00:04');
INSERT INTO {{%city_weather}} VALUES ('5', '63', 'guangzhou', 'c_guangzhou', 'CNGDGZ00', '广州', '9', '16', '17', '1', '2015-03-13 15:42:36');
INSERT INTO {{%city_weather}} VALUES ('6', '64', 'shenzhen', 'c_shenzhen', 'CNGDSZ00', '深圳', '9', '16', '17', '1', '2015-03-13 08:00:06');
INSERT INTO {{%city_weather}} VALUES ('7', '228', 'shijiazhuang', 'c_shijiazhuang', 'CNHESJ00', '石家庄', '8', '16', '19', '1', '2015-03-13 15:42:38');
INSERT INTO {{%city_weather}} VALUES ('8', '34', 'nanjing', 'c_nanjing', 'CNJSNJ00', '南京', '9', '16', '18', '1', '2015-03-13 15:42:39');
INSERT INTO {{%city_weather}} VALUES ('9', '300', 'hangzhou', 'c_hangzhou', 'CNZJHZ00', '杭州', '10', '16', '18', '1', '2015-03-13 15:42:39');
INSERT INTO {{%city_weather}} VALUES ('10', '518', 'shenyang', 'c_shenyang', 'CNLNSY00', '沈阳', '6', '16', '17', '1', '2015-03-13 15:42:40');
INSERT INTO {{%city_weather}} VALUES ('11', '294', 'hefei', 'c_hefei', 'CNAHHF00', '合肥', '9', '16', '19', '1', '2015-03-13 15:42:40');
INSERT INTO {{%city_weather}} VALUES ('12', '230', 'fuzhou', 'c_fjfuzhou', 'CNFJFZ00', '福州', '9', '16', '18', '1', '2015-03-13 15:42:41');
INSERT INTO {{%city_weather}} VALUES ('13', '27', 'guiyang1', 'c_guiyang', 'CNGZGY00', '贵阳', '8', '16', '18', '1', '2015-03-13 08:00:10');
INSERT INTO {{%city_weather}} VALUES ('14', '65', 'nanning', 'c_nanning', 'CNGXNN00', '南宁', '8', '16', '17', '1', '2015-03-13 08:00:10');
INSERT INTO {{%city_weather}} VALUES ('15', '259', 'lanzhou', 'c_lanzhou', 'CNGSLZ00', '兰州', '8', '16', '18', '1', '2015-03-13 15:42:42');
INSERT INTO {{%city_weather}} VALUES ('16', '505', 'haikou', 'c_haikou', 'CNHIHK00', '海口', '10', '16', '17', '1', '2015-03-13 08:00:11');
INSERT INTO {{%city_weather}} VALUES ('17', '40', 'haerbin', 'c_harbin', 'CNHLHE00', '哈尔滨', '5', '16', '18', '1', '2015-03-13 15:42:43');
INSERT INTO {{%city_weather}} VALUES ('18', '201', 'wuhan', 'c_wuhan', 'CNHBWH00', '武汉', '9', '16', '19', '1', '2015-03-13 12:00:52');
INSERT INTO {{%city_weather}} VALUES ('19', '358', 'changsha', 'c_changsha', 'CNHNCS00', '长沙', '8', '16', '18', '1', '2015-03-13 12:00:53');
INSERT INTO {{%city_weather}} VALUES ('20', '67', 'zhengzhou', 'c_zhengzhou', 'CNHAZZ00', '郑州', '9', '16', '21', '1', '2015-03-13 15:42:44');
INSERT INTO {{%city_weather}} VALUES ('21', '307', 'changchun', 'c_changchun', 'CNJLCC00', '长春', '5', '16', '17', '1', '2015-03-13 15:42:45');
INSERT INTO {{%city_weather}} VALUES ('22', '374', 'nanchang', 'c_nanchang', 'CNJXNC00', '南昌', '9', '16', '18', '1', '2015-03-13 15:42:46');
INSERT INTO {{%city_weather}} VALUES ('23', '20', 'huhehaote', 'c_huhhot', 'CNNMHH00', '呼和浩特', '6', '16', '17', '1', '2015-03-13 12:00:54');
INSERT INTO {{%city_weather}} VALUES ('24', '31', 'ningchuan', 'c_yinchuan', 'CNNXYC00', '银川', '9', '16', '19', '1', '2015-03-13 15:42:46');
INSERT INTO {{%city_weather}} VALUES ('25', '466', 'xining', 'c_xining', 'CNQHXN00', '西宁', '8', '16', '18', '1', '2015-03-13 15:42:47');
INSERT INTO {{%city_weather}} VALUES ('26', '486', 'chengdu', 'c_chengdu', 'CNSCCD00', '成都', '9', '16', '18', '1', '2015-03-13 15:42:47');
INSERT INTO {{%city_weather}} VALUES ('27', '54', 'xian', 'c_xian', 'CNXAXA00', '西安', '9', '16', '19', '1', '2015-03-13 15:42:48');
INSERT INTO {{%city_weather}} VALUES ('28', '373', 'taiyuan', 'c_taiyuan', 'CNSXTY00', '太原', '8', '16', '17', '1', '2015-03-13 15:42:48');
INSERT INTO {{%city_weather}} VALUES ('29', '33', 'ninan', 'c_jinan', 'CNSDJN00', '济南', '9', '16', '19', '1', '2015-03-13 15:42:49');
INSERT INTO {{%city_weather}} VALUES ('30', '215', 'kunming', 'c_lasa', 'CNXZLS00', '拉萨', '10', '16', '17', '1', '2015-03-13 15:42:49');
INSERT INTO {{%city_weather}} VALUES ('31', '455', 'wulumuqi', 'c_urumqi', 'CNXJWL00', '乌鲁木齐', '6', '16', '17', '1', '2015-03-13 15:42:50');
INSERT INTO {{%city_weather}} VALUES ('32', '179', 'kunming', 'c_kunming', 'CNYNKM00', '昆明', '10', '16', '17', '1', '2015-03-13 15:42:50');
INSERT INTO {{%city_weather}} VALUES ('33', '24', 'hongkong', null, 'CNHK0000', '中国香港', '9', '16', '17', '1', '2015-03-04 08:00:44');
FINE;
		$this->execute($sql);
    }

    public function down()
    {
		$sql =<<<FINE
-- ----------------------------
-- Table structure for city_weather
-- ----------------------------
DROP TABLE IF EXISTS {{%city_weather}};
FINE;

       	$this->execute($sql);
    }
}
